<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
  <!--    引入css 样式-->
  <link rel="stylesheet"  href="/layui/css/layui.css">
  <!--    引入js -->
  <script src="/layui/layui.js"></script>
</head>
<body>
<div>
  <button type="button" class="layui-btn" id="test1">
    <i class="layui-icon">&#xe67c;</i>导入数据
  </button>
  <button type="button" class="layui-btn" onclick="downLoad()">
    <i class="layui-icon">&#xe67c;</i>下载数据
  </button>
  <script>
    layui.use('upload', function(){
      var upload = layui.upload;

      //执行实例
      var uploadInst = upload.render({
        elem: '#test1' //绑定元素
        ,accept:"file"
        ,url: '/api/food/upload.do' //上传接口
        ,done: function(res){
          //上传完毕回调
          if(res.code==0){
            layer.msg("亲，导入成功！");
            location.href="list.html";
          }else {
            layer.msg("亲，导入数据失败？");
          }
        }
        ,error: function(){
          //请求异常回调
        }
      });
    });
    function downLoad(){
      //实现数据的下载
      location.href="/api/project/download.do";
    }
  </script>
</div>
</body>
</html>